package com.qzxy.premiumhotelsystem.service.impl;

import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qzxy.premiumhotelsystem.domain.entity.Logs;
import com.qzxy.premiumhotelsystem.service.LogsService;
import com.qzxy.premiumhotelsystem.mapper.LogsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author iQNRen
 * @description 针对表【logs】的数据库操作Service实现
 * @createDate 2024-09-18 11:20:26
 */
@Service
public class LogsServiceImpl extends ServiceImpl<LogsMapper, Logs>
        implements LogsService {

    @Autowired
    private LogsMapper logsMapper;

    /**
     * 查询所有日志
     *
     * @return
     */
    @Override
    public List<Logs> allLogs(String sortOrder) {
        if ("desc".equalsIgnoreCase(sortOrder)) {
            return logsMapper.allLogs();
        } else {
            return logsMapper.allLogsDesc();
        }

    }

    /**
     * 分页查询日志
     *
     * @param pageSize
     * @param limit
     * @return
     */
    @Override
    public PageInfo<Logs> allLogsForPage(Integer pageSize, Integer limit,String sortOrder) {
        Page<Logs> page = PageHelper.startPage(pageSize, limit);
        if ("desc".equalsIgnoreCase(sortOrder)) {
            List<Logs> logs = logsMapper.allLogsDesc();
        } else {
            List<Logs> logs = logsMapper.allLogs();
        }
        return page.toPageInfo();
    }

    /**
     * 插入日志
     * @param logLevel
     * @param logUser
     * @param logContent
     * @return
     */
    @Override
    public boolean create(String logLevel, String logUser, String logContent) {
        return logsMapper.create(logLevel,logUser,logContent);
    }

    /**
     * 根据id删除日志
     * @param logId
     * @return
     */
    @Override
    public boolean delByLogIdBoolean(String logId) {
        return logsMapper.delByLogIdBoolean(logId);
    }

    /**
     * 根据id更新日志
     * @param logs
     * @return
     */
    @Override
    public boolean updateIdBoolean(Logs logs) {
        return logsMapper.updateIdBoolean(logs);
    }
}




